/**
 * 
 */
package com.totobox.apps.common;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.RadioButton;

import com.totobox.apps.Const;
import com.totobox.apps.R;
import com.totobox.apps.activity.MyFavoriteActivity;
import com.totobox.apps.activity.MyStorageActivity;

/**
 * @author ytslove
 * 
 */
public class SortCustomDialog extends Dialog {

	private RadioButton radio_name;
	private RadioButton radio_date;
	private RadioButton radio_size;
	private Activity atv;
	private Class cls = null;
	
	public SortCustomDialog(Activity atv) {
		super(atv);
		this.atv = atv;
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		this.setContentView(R.layout.dialog_sort_view);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		if(atv instanceof MyStorageActivity){
			cls = MyStorageActivity.class;
		}
		else{
			cls = MyFavoriteActivity.class;
		}
		
		radio_name = (RadioButton)findViewById(R.id.radio_name);
		radio_date = (RadioButton)findViewById(R.id.radio_date);
		radio_size = (RadioButton)findViewById(R.id.radio_size);
		
		radio_name.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				radio_name.setChecked(false);
				Const.sortName = "vcName";
				dismiss();
				
				MoveActivity go = new MoveActivity(atv, cls);
				go.startActivity();
			}
		});
		radio_date.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				radio_date.setChecked(false);
				Const.sortName = "dtRegDate desc";
				dismiss();
				
				MoveActivity go = new MoveActivity(atv, cls);
				go.startActivity();
			}
		});
		radio_size.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				radio_size.setChecked(false);
				Const.sortName = "iFileSize desc";
				dismiss();
				
				MoveActivity go = new MoveActivity(atv, cls);
				go.startActivity();
			}
		});
	}

}
